#pragma once
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

//这个类主要是将sockaddr_in中的ip port提取出来
class InetAddr
{
public:
    InetAddr(sockaddr_in addr):_addr(addr)
    {
        _ip = inet_ntoa(_addr.sin_addr);
        _port = ntohs(_addr.sin_port);
    }
    std::string GetIp()
    {
        return _ip;
    }
    uint16_t Get_Port()
    {
        return _port;
    }
    ~InetAddr(){}
private:
sockaddr_in _addr;
std::string _ip;
uint16_t _port;
};